using ASPNetCoreExecutor.Jobs;
using DotPowerJob;
using DotPowerJob.Extensions;
using System.Threading.Tasks.Dataflow;

namespace ASPNetCoreExecutor
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.
            builder.Services.AddRazorPages();

            builder.Services.AddPowerJobExecutor(builder.Configuration);

            builder.Services.AddSingleton<IJobHandler, DemoJobHandler>();

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (!app.Environment.IsDevelopment())
            {
                app.UseExceptionHandler("/Error");
            }
            
            app.UsePowerJobExecutor();

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.MapRazorPages();

            app.Run();
        }
    }
}
